﻿using System;
using System.Web;
using Autofac;
using Common.Extensions;
using Common.Logger;
using WebSockets.DI;

namespace WebSockets
{
    public class Global : HttpApplication
    {
        static public IContainer DIContainer { get; private set; }

        protected void Application_Start(object sender, EventArgs e)
        {
            Logger.Initialize();
            Logger.Instance.Info("Starting WS server");
            Logger.ThreadName = "Main Application";
            DIContainer = new DIContainerFactory().Create();
        }

        protected void Session_Start(object sender, EventArgs e)
        {

        }

        protected void Application_BeginRequest(object sender, EventArgs e)
        {

        }

        protected void Application_AuthenticateRequest(object sender, EventArgs e)
        {

        }

        protected void Application_Error(object sender, EventArgs e)
        {            
            Logger.Instance.ErrorFormat("There was an error: ", Context.Error.GetMessage());
        }

        protected void Session_End(object sender, EventArgs e)
        {

        }

        protected void Application_End(object sender, EventArgs e)
        {

        }
    }
}